<#include "/common/head.ftl">

<@showTitle title="${i18n.getMessage('internalReceipt')} > ${i18n.getMessage('internalReceipt.list')}">
	<a href="#" onclick="selectAll()">${i18n.getMessage('Select All')}</a> - 
	<a href="#" onclick="deleteReceipts()">${i18n.getMessage('delete')}</a>
</@showTitle>

<br/>

<form id="form" onreset="$('error').hide()">
<@display.table id="listTable" name="receipts" sort="list" defaultorder="descending" defaultsort="2">
	<@display.column title="${i18n.getMessage('select')}" class="center w030"><input type="checkbox" name="ids" value="${(listTable.id)!}"/></@display.column>
	<@display.column title="${i18n.getMessage('number')}" class="w100"><a href="#" onclick="cc('receipt/showInternalReceipt.sgt?id=${listTable.id}')"><#if (listTable.number)?has_content>${(listTable.number)!}<#else>None</#if></a></@display.column>
	<@display.column title="${i18n.getMessage('name')}" class="w175" property="name" sortable="true"></@display.column>
	<@display.column title="${i18n.getMessage('date')}" property="date" format="{0,date,${i18n.getMessage('format.date')}}" sortable="true" class="center w080"></@display.column>
	<@display.column title="${i18n.getMessage('fee')} (${i18n.getMessage('currency.vnd')})" sortable="true" class="right w080">${(listTable.fee.amount?string('#,##0'))!}</@display.column>
	<@display.column title="${i18n.getMessage('cashier')}" class="w175" property="cashier.fullName" sortable="true"></@display.column>
	<@display.column title="${i18n.getMessage('comment')}" property="comment" sortable="true"></@display.column>
</@display.table>
</form>
<br><br>

<script>

selectAll = function() {
	var form = $('form');
	var count = 0;
	form.getInputs('checkbox').each(function(input) {
		if(input.checked)
			count++;
	});
	if(count > 0) {
		form.getInputs('checkbox').each(function(input) {
			input.checked = false;
		});
	}
	else {
		form.getInputs('checkbox').each(function(input) {
			input.checked = true;
		});
	}
}

deleteReceipts = function() {
	var form = $('form');
	form.action = 'receipt/deleteReceipts.sgt';
	submitForm(form);
}
</script>